// src/api/allAPI.ts
import axios from 'axios';
import {pageItem} from "./req";

export const baseURL = 'http://119.23.78.227:1337';

const request = axios.create({
    baseURL,
    timeout: 35000
});

/**
 * 政策法规数据
 * @param req
 */
export function getPlantQuarantineAPI(req: pageItem) {
    return request({
        url: '/api/plant-quarantines',
        params: {
            'pagination[page]': req.pageNo,
            'pagination[pageSize]': req.pageSize,
            populate: '*'
        }
    });
}

/**
 * 入侵物种名录数据
 * @param req
 */
export function getInvasiveSpeciesDirectoryAPI(req: pageItem) {
  return request({
    url: '/api/list-of-invasive-species',
    params: {
      'pagination[page]': req.pageNo,
      'pagination[pageSize]': req.pageSize,
      populate: '*',
      filters: {
        $or: [
          { ScientificName: { $contains: req.searchTerm } },
          { ChineseName: { $contains: req.searchTerm } }
        ]
      }
    }
  })
}

/**
 * 行业动态数据
 * @param req
 */
export function getIndustryDynamicAPI(req: pageItem) {
  return request({
    url: '/api/industry-dynamics',
    params: {
        'pagination[page]': req.pageNo,
        'pagination[pageSize]': req.pageSize,
        populate: '*'
    }
  })
}

/**
 * 相关链接--政府部门
 */
export function getGovernmentAPI(req: pageItem) {
  return request({
    url: '/api/government-department-links',
    params: {
        'pagination[page]': req.pageNo,
        'pagination[pageSize]': req.pageSize,
        populate: '*'
    }
  })
}

/**
 * 相关链接--研究论文
 */
export function getResearchAPI(req: pageItem) {
  return request({
    url: '/api/research-paper-links',
    params: {
        'pagination[page]': req.pageNo,
        'pagination[pageSize]': req.pageSize,
        populate: '*'
    }
  })
}